import { Controller, Get, Render } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { ApiTags } from '@nestjs/swagger';
import { QiniuService } from 'src/component/qiniu/qiniu.service';

@ApiTags('其他模块')  
@Controller()
export class UploadFormController {
  constructor(
    private readonly configService: ConfigService,
    private readonly qiniuService: QiniuService,
  ) {}

  @Get('/nest-vue-short-passage/upload-form')
  @Render('upload-form/index') //使用render渲染模板引擎，参数就是文件路径：default文件夹下的index.ejs
  async uploadForm(): Promise<any> {
    const { qiniuHost } = this.configService.get('qiniu');
    const ret: any = await this.qiniuService.getQiniuAll(50);
    return {
      qiniuHost,
      list: ret.items,
    }; //只有返回参数在模板才能获取，如果不传递参数，必须返回一个空对象
  }
}
